<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
<link href="style/authority/basic_layout.css" rel="stylesheet"
	type="text/css">
<link href="style/authority/common_style.css" rel="stylesheet"
	type="text/css">
<script type="text/javascript"
	src="scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" type="text/css"
	href="style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>

<title>类别管理</title>
<script type="text/javascript">
window.onload=function(){showall();} 
function showall(){
	getcla_ele();
	getele();
}
	function getele(){
	
		$.ajax({
		url:"element.action?showEle",
		type:"POST",
		datatype:"text",
		data:"",
	     error: function() {
     
			
		},
		success:function(data){
			//alert(1);
			getele1(data);
			
		}
	})  
	} 
	//获得上部分要素
	function getele1(data){
	 		
			$("#list1").html("");
			 for (var key in data){
				
				 $("#list1").html($("#list1").html()
				+"<option value="+data[key].eid+">"+data[key].ename+"</option>");  
			}  
	} 
	function getcla_ele(){
		 $.ajax({
		url:"e_Cla.action?showE_Cla",
		type:"POST",
		datatype:"text",
		data:"",
		 error: function(XMLHttpRequest, textStatus, errorThrown) {
	    	 alert(XMLHttpRequest.status);
             alert(XMLHttpRequest.readyState);
             alert(textStatus);
			
		},
		success:function(data){
			getall(data);
		}
	})   
	} 
	//获得下部分表格
	function getall(data){
	 		
			$("#cla_ele").html("");
			 for (var key in data){
				//alert(data[key].claid+","+data[key].claname);
				//alert(data[key].ele);
					var yaosu = "";
					 //alert(listsize);
					for(var ke in data[key].ele){
						//alert(data[key].ele[ke].ename);
						yaosu += data[key].ele[ke].ename+" , ";
					}
					//alert(yaosu);
					 $("#cla_ele").html($("#cla_ele").html()+
								"<tr>"
							+"<td width=\"30\">"
								+"<input type=\"checkbox\" name=\"IDCheck\" value=\""+data[key].claid+"\" class=\"acb\" />"
							+"</td>"
							+"<td >"+data[key].claname+"</td>"
							+"<td>"+
							yaosu
							+"</td>"
							+"<td>"
								+"<a href=\"house_edit.html?fyID=14458579642011\" class=\"edit\">编辑</a>" 
								+"<a href=\"javascript:del('14458579642011');\">删除</a>"
							+"</td>"
							+"</tr>"
								 );
				
				
				  
			 }  
	} 
 		
	 			

function moveOption(e1,e2)
{
  try
  {
    for(var i=0;i<e1.options.length;i++)
    {
      if(e1.options[i].selected)
      {
        var e = e1.options[i];
        e2.options.add(new Option(e.text, e.value));
        e1.remove(i);
        i=i-1
      }
    }
    document.getElementById('city').value=getvalue(document.getElementById('list2'));
  }
  catch(e){}
}
function getvalue(geto)
{
  var allvalue = "";
  for(var i=0;i<geto.options.length;i++)
  {
    allvalue +=geto.options[i].value + ",";
  }
  return allvalue;
}

 function addcla_ele(){
	var claname=$("#fyZldz1").val();
	var select = document.getElementById("list2");
	var array=new Array();
	for (var i = 0; i<select.length; i++){
		array.push(select.options[i].value);
	}
	if((""!=claname)&&(null!=claname)&&(array.length>0)){
		$.ajax({
			url:"e_Cla.action?addE_Cla",
			type:"POST",
			datatype:"text",
			data:"claname="+claname+"&"+"elelist="+array,
		     error: function() {
	     
				
			},
			success:function(data){
				//alert(1);
				if("0".equals(data)){
					alert("该类别已存在！");
				}
				
			}
		}) 
	}else{
	alert("类别名不能为空！");
	}
	
	
	//alert(claname);
} 
</script>
<!-- 将左边加入右边 END -->
<style>
.alt td {
	background: black !important;
}
</style>
</head>
<!--  onload="getele()"-->
<body>
	<form id="submitForm" name="submitForm" action="" method="post">
		<input type="hidden" name="allIDCheck" value="" id="allIDCheck" /> <input
			type="hidden" name="fangyuanEntity.fyXqName" value="" id="fyXqName" />
		<div id="container">
			<div class="ui_content">
				<div class="ui_text_indent">
					<div id="box_border">
						<div id="box_top">添加类别</div>
						<div id="box_center1">
							类别名称&nbsp; <input type="text" id="fyZldz1"
								name="fangyuanEntity.fyZldz" class="ui_input_txt02" />


							<!-- 左加右 -->
							<div align="center">
								<div
									style="border: 0px solid #8A8A8A; padding-bottom: 30px; width: 800px;">
									<form id="myform" name="myform" method="post">
										<table align="center" border="0">
											<tr>
												<th colspan="3"><h3>要素选择</h3></th>
											</tr>
											<tr>
												<!-- 左 -->
												<td align="center"><select
													style="width: 342px; height: 260px;" multiple id="list1"
													name="list1" size="6"
													ondblclick="moveOption(this, document.getElementById('list2'))">
														<option value="要素1">要素1</option>
														<option value="要素2">要素2</option>
														<option value="要素3">要素3</option>
														<option value="要素4">要素4</option>
														<option value="要素5">要素5</option>
														<option value="要素6">要素6</option>
												</select></td>
												<!-- 左 END -->

												<!-- 中 -->
												<td align="center"><input type="button" value="添加"
													onclick="moveOption(document.getElementById('list1'), document.getElementById('list2'))"><br>
													<br /> <input type="button" value="删除"
													onclick="moveOption(document.getElementById('list2'), document.getElementById('list1'))">
												</td>
												<!-- 中 END -->

												<!-- 右 -->
												<td align="center"><select
													style="width: 342px; height: 260px;" multiple id="list2"
													name="list2" size="6"
													ondblclick="moveOption(this, document.getElementById('list1'))">
												</select></td>
												<!-- 右 END -->
											</tr>
										</table>
									</form>
								</div>
							</div>
							<!-- 左加右 END -->
							<div style="text-align: right">
								<input type="button" value="添加" class="ui_input_btn01" id=""
									onclick="addcla_ele()" />
							</div>
						</div>

					</div>
				</div>
			</div>
			<div class="ui_content">
				<div class="ui_tb">
					<table class="table" cellspacing="0" cellpadding="0" width="100%"
						align="center" border="0">
						<tr>
							<th width="30"><input type="checkbox" id="all"
								onclick="selectOrClearAllCheckbox(this);" /></th>
							<th>类别名称</th>
							<th>包含要素</th>
							<th>操作</th>

						</tr>
						<tbody id="cla_ele">
							<tr>
								<td width="30"><input type="checkbox" name="IDCheck"
									value="14458579642011" class="acb" /></td>
								<td>环境站</td>
								<td>要素1,&nbsp;要素1&nbsp;要素1&nbsp;要素1<br>要素1要素1要素1要素1要素1要素1
								</td>

								<td><a href="house_edit.html?fyID=14458579642011"
									class="edit">编辑</a> <a href="javascript:del('14458579642011');">删除</a></td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="ui_tb_h30">
					<div class="ui_flt" style="height: 30px; line-height: 30px;">
						共有 <span class="ui_txt_bold04">90</span> 条记录，当前第 <span
							class="ui_txt_bold04">1 / 9</span> 页
					</div>
					<div class="ui_frt">
						<!--    如果是第一页，则只显示下一页、尾页 -->

						<input type="button" value="首页" class="ui_input_btn01" /> <input
							type="button" value="上一页" class="ui_input_btn01" /> <input
							type="button" value="下一页" class="ui_input_btn01" onclick="" /> <input
							type="button" value="尾页" class="ui_input_btn01" onclick="" />



						<!--     如果是最后一页，则只显示首页、上一页 -->

						转到第<input type="text" id="jumpNumTxt" class="ui_input_txt01" />页
						<input type="button" class="ui_input_btn01" value="跳转" onclick="" />
					</div>
				</div>
			</div>
		</div>
	</form>

</body>
</html>
